<template>
	<!-- <vxe-toolbar size="mini" :buttons="toolbarButtons" @button-click="buttonClickEvent" ref="toolbarRef"
		custom></vxe-toolbar> -->
	<vxe-table ref="tableRef" size="mini" height="1000" max-height="800" align="center" border stripe
		:row-config="{ isCurrent: true, isHover: true }" :data="tableData" keep-source>
		<vxe-column type="seq" width="70"></vxe-column>
		<vxe-column type="checkbox" width="50" align="center"></vxe-column>
		<vxe-column field="id" title="报价单号" show-overflow></vxe-column>
		<vxe-column field="inquiryNumber" title="报价单完整编号" show-overflow></vxe-column>
		<vxe-column field="companyId" title="公司Id" show-overflow></vxe-column>
		<vxe-column field="companyName" title="客户名称" show-overflow></vxe-column>
		<vxe-column field="customerInquiryStatus" title="报价单状态" show-overflow></vxe-column>
		<vxe-column field="createdOn" title="创建时间" show-overflow></vxe-column>
		<vxe-column field="quotedOn" title="报价时间" show-overflow></vxe-column>
		<vxe-column field="expiredOn" title="过期时间" show-overflow></vxe-column>
		<vxe-column field="totalAmount" title="总金额"></vxe-column>
		<vxe-column field="comment" title="备注" show-overflow></vxe-column>
		<vxe-column field="action" title="操作" width="140">
			<template #default="{ row }">
				<vxe-button size="mini" status="primary" @click="toDetail(row)">查看</vxe-button>
			</template>
		</vxe-column>
	</vxe-table>
	<vxe-pager @page-change="handlePageChange" :current-page.sync="pageVO4.currentPage"
		:page-size.sync="pageVO4.pageSize" :total="pageVO4.total" size="mini" :page-sizes="[100, 300, 500, 700, 1000]"
		:layouts="[
			'PrevJump',
			'PrevPage',
			'Number',
			'NextPage',
			'NextJump',
			'FullJump',
			'Sizes',
			'Total',
		]" />
</template>

<script setup>
import { VxeUI } from "vxe-table";
import { ref, onMounted } from "vue";
const tableData = ref([{}]);
const tableRef = ref(null);
const pageVO4 = {
	currentPage: 1,
	pageSize: 100,
	total: 0,
};
const toolbarButtons = [
	{
		name: "刷新",
		code: "刷新",
	},
];
const handlePageChange = ({ type, currentPage, pageSize, $event }) => {
	pageVO4.currentPage = currentPage;
	pageVO4.pageSize = pageSize;
	getList();
};
const getList = () => {
	VxeUI.loading.open({
        text: '数据加载中，请稍后...'
      })
	Meteor.call("getQuotationList", pageVO4, (err, res) => {
		if (err) {
			console.error("调用错误:", err.message);
		} else {
			tableData.value = res.data.list;
			pageVO4.total = res.data.page.total;
			pageVO4.currentPage = res.data.page.pageIndex;
			pageVO4.pageSize = res.data.page.pageSize;
			VxeUI.loading.close()
		}
	});
};
//详情页
const toDetail = (row) => {
	console.log(row);
	window.location.href = `/quotation-detail/${row.id}`;
};
onMounted(() => {
	getList();
});
</script>
